import java.rmi.Naming;
import java.rmi.RemoteException;
import java.net.MalformedURLException;

public class CalculServer {

	static String bank = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
	
	public static String random(int n) {
        String output = "";
        for (int i = 0; i<n; i++) {
            output+= bank.charAt((int) Math.round(Math.random()*25));
        }
        return output;
    }
	public static void main(String[] args) {
		
  //      String a = random(24000);
    //    String b = random(10000);
		
		String a = "WAAADAAFSF";
		String b = "AAFDSNFPDGVUGMTUGKIGUJGTUDEGWRGRGIRHGIOWHFIOFUWEGFHEGORWHGORWGHRGHRWGRWHUWRGURWHGFGFKGDUR";
        String c = "GBJNFSDGBDFD";
		long time = System.currentTimeMillis();
        System.out.println("taille de a : " + a.length());
       // for (int pute  = 0; pute<1000; pute++) {
       // 	a = a+b;
       // }
        System.out.println("taille de a : " + a.length());
        time = System.currentTimeMillis() -time;
        int result = Distance.distance(a, c);
        System.out.println(result);
        System.out.println("Temps d'execution :"+time);

	//	String a = "AAAAAAAA";
	//	String b = "ADSDSDSDDSFFDFSDSGHFFHDHDGHDHDHAA";
		int n = 4; //nbre de processeurs
		try {
			Info inf = new Info(n,a,c);
			Naming.rebind("rmi://localhost:1143/Info", inf);
			for(int k = 1; k <= n; k++){
				Calcul obj = new Calcul(n,k,a,c);
				Naming.rebind("rmi://localhost:1143/Calcul" + k, obj);
			}
		}
		catch (RemoteException e){
			System.out.println(e);
			System.out.println("Remote problem while binding \"Hello\"-server.");	    
		} catch (MalformedURLException e){
			System.out.println("bad URL");
		}
		System.out.println("Servers for \"Calcul\" are up.");
	}

}
